package edu.ccut.saturn.studio.naviagtor;

import org.eclipse.swt.graphics.Image;


//import cn.edu.ccut.icons.ISaturnIcons;
import edu.ccut.saturn.studio.Activator;
import edu.ccut.saturn.studio.Images;

/**
 * Saturn 文件类型
 * 
 * @author alf 2008-7-17
 */
public class SaturnFile {

	public static String LOGIC_FILE_SUFFIX = "logic";
	public static String ACTION_FILE_SUFFIX = "action";
	public static String COMPONENT_FILE_SUFFIX = "component";
	public static String JSP_FILE_SUFFIX = "jsp";
	public static String VALIDATE_FILE_SUFFIX = "validate";
	public static String WORKFLOW_FILE_SUFFIX = "wf";
	public static String SATURN_DATA_FILE_SUFFIX = "saturndata";

	public static boolean isSaturnFile(String name) {
		return name.endsWith(SaturnFile.ACTION_FILE_SUFFIX)
				|| name.endsWith(SaturnFile.COMPONENT_FILE_SUFFIX)
				|| name.endsWith(SaturnFile.LOGIC_FILE_SUFFIX)
				|| name.endsWith(SaturnFile.JSP_FILE_SUFFIX)
				|| name.endsWith(SaturnFile.VALIDATE_FILE_SUFFIX)
				|| name.endsWith(SaturnFile.WORKFLOW_FILE_SUFFIX)
				|| name.endsWith(SaturnFile.SATURN_DATA_FILE_SUFFIX);
	}

	public static Image getImageFromDiretoryType(String saturnType) {
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_ACTION)) {
			return Activator.getImage(Images.ACTION_FOLDER_ICON);
		}
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_LOGIC)) {
			return Activator.getImage(Images.LOGIC_FOLDER_ICON);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_COMPONENT)) {
			return Activator.getImage(Images.COMPONENT_FOLDER_ICON);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_DATA)) {
			return Activator.getImage(Images.DATA_FOLDER_ICON);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_PAGE)) {
			return Activator.getImage(Images.PAGE_FOLDER_ICON);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_VALIDATE)) {
			return Activator.getImage(Images.VALIDATE_FOLDER_ICON);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_WORKFLOW)) {
			return Activator.getImage(Images.WORKFLOW_FOLDER_ICON);
		}
		
		return Activator.getImage(Images.MODEl_FOLDER_ICON);
	}
	
	public static Image getImageFromFileType(String saturnType) {
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_ACTION)) {
			return Activator.getImage(Images.NEWSATURN_ACTION_ACTION);
		}
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_LOGIC)) {
			return Activator.getImage(Images.LOGIC_ICON_SMALL);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_COMPONENT)) {
			return Activator.getImage(Images.COMPONENT_ICON_SMALL);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_SATURN_DATA)) {
			return Activator.getImage(Images.NEWSATURN_DATAITEM_ACTION);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_JSP_PAGE)) {
			return Activator.getImage(Images.SATURN_PAGE_MIN);
		}
		
		if (saturnType.equalsIgnoreCase(SaturnDirectory.TYPE_VALIDATE)) {
			return Activator.getImage(Images.NEWSATURN_VALIDATE_ACTION);
		}
		
		if (saturnType.equalsIgnoreCase(WORKFLOW_FILE_SUFFIX)) {
			return Activator.getImage(Images.WORK_FLOW_SMALL);
		}
		
		return null;
	}
}
